<%@page import="multiface.awwadco.jpa.Utente"%>
<%
    Utente ut = (Utente) session.getAttribute("admin");
    if (ut == null) {
        response.sendRedirect(multiface.web.util.ServletUtils.getBaseUrl(request) + "/admin/index.jsp?err=y");
    }
%>

<%@page import="multiface.web.util.categories.AlberoCategorieProdotti"%>
<%@page import="multiface.awwadco.jpa.Categoria"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="javax.persistence.Persistence"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page import="multiface.awwadco.jpa.PersistenceManager"%>
<%
    int cid = Integer.parseInt(request.getParameter("cid"));

    AlberoCategorieProdotti tree = new AlberoCategorieProdotti();
    tree.caricaDaDB();

    EntityManagerFactory emf = PersistenceManager.getInstance().getEntityManagerFactory();
    EntityManager em = emf.createEntityManager();

    int nopt = tree.numeroFigli(new Categoria(cid));

    String pre = tree.Percorso(new Categoria(cid));

    out.print("Position: <select id=\"select-moveto-pos\">");
    if(nopt==0)out.println("<option value=\"0\">"+pre+"1</option>");
    for (int i = 0; i < nopt; i++) {
        out.println("<option value=\"" + i + "\">" + pre + (i + 1) + "</option>");
    }
    out.print("</select>");
    em.close();
    //emf.close();
%>
<div><input onclick="javascript:move_cat('prod','list_prod_cat.jsp');" type="button" value="Move"></input> </div>